package com.xjscrm.console.web.groupPull;

import com.xjscrm.console.param.groupPull.*;
import com.xjscrm.console.param.groupSend.BatchUpdateSleepRuleDto;
import com.xjscrm.console.param.operatePlan.EffectuateGroupDto;
import com.xjscrm.console.param.wwDevice.WwDeviceQuery;
import com.xjscrm.console.service.customer.groupPull.BatchGroupPullTaskService;
import com.xjscrm.console.service.customer.groupPull.GroupPullTaskService;
import com.xjscrm.console.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "批量拉群管理", tags = "批量拉群管理")
@RestController
@RequestMapping(value = "/groupPull")
public class GroupPullController {

    @Autowired
    private GroupPullTaskService groupPullTaskService;

    @Autowired
    private BatchGroupPullTaskService batchGroupPullTaskService;


    @ApiOperation(value = "新增批量拉群任务", notes = "新增批量拉群任务",response = Boolean.class)
    @PostMapping(value ="/addGroupPullTask" )
    public Object addGroupPullTask(@RequestBody GroupPullTaskDto groupPullTaskDto)throws Exception{
        groupPullTaskService.addGroupPullTask(groupPullTaskDto);
        return true;
    }

    @ApiOperation(value = "获取批量拉群任务列表", notes = "获取批量拉群任务列表",response = GroupPullTaskVo.class)
    @PostMapping(value ="/getGroupPullTaskList" )
    public Object getGroupPullTaskList(@RequestBody GroupPullTaskQuery groupPullTaskQuery)throws Exception{
        return groupPullTaskService.getGroupPullTaskList(groupPullTaskQuery);
    }


    @ApiOperation(value = "获取批量拉群任务详情", notes = "获取批量拉群任务详情",response = GroupPullTaskVo.class)
    @PostMapping(value ="/getGroupPullTaskDetail" )
    public Object getGroupPullTaskDetail(@RequestBody GroupPullTaskDto groupPullTaskDto)throws Exception{
        return    groupPullTaskService.getGroupPullTaskDetail(groupPullTaskDto);
    }

    @ApiOperation(value = "修改批量拉群任务", notes = "修改批量拉群任务",response = Boolean.class)
    @PostMapping(value ="/updateGroupPullTask" )
    public Object updateGroupPullTask(@RequestBody GroupPullTaskDto groupPullTaskDto)throws Exception{
        groupPullTaskService.updateGroupPullTask(groupPullTaskDto);
        return true;
    }


    @ApiOperation(value = "删除批量拉群任务", notes = "删除批量拉群任务",response = Boolean.class)
    @PostMapping(value ="/deleGroupPullTask" )
    public Object deleGroupPullTask(@RequestBody DelGroupPullTaskDto delGroupPullTaskDto) throws Exception{
        groupPullTaskService.deleGroupPullTask(delGroupPullTaskDto);
        return true;
    }


    @ApiOperation(value = "获取拉群任务执行列表", notes = "获取拉群任务执行列表",response = GroupPullJobVo.class)
    @PostMapping(value ="/getGroupPullJobList" )
    public Object getGroupPullJobList(@RequestBody GroupPullJobQuery groupPullJobQuery)throws Exception{
    return groupPullTaskService.getGroupPullJobList(groupPullJobQuery);
    }

    @ApiOperation(value = "获取拉群任务执行机器人列表", notes = "获取拉群任务执行机器人列表",response = GroupPullJobDeviceVo.class)
    @PostMapping(value ="/getGroupPullJobDeviceList" )
    public Object getGroupPullJobDeviceList(@RequestBody GroupPullJobDeviceDto groupPullJobDeviceDto)throws Exception{
        return groupPullTaskService.getGroupPullJobDeviceList(groupPullJobDeviceDto);
    }

    @ApiOperation(value = "获取拉群任务执行任务详情列表", notes = "获取拉群任务执行任务详情列表",response = GroupPullJobMsgVo.class)
    @PostMapping(value ="/getGroupPullJobMsgList" )
    public Object getGroupPullJobMsgList(@RequestBody GroupPullJobMsgQuery GroupPullJobMsgQuery)throws Exception{
        return groupPullTaskService.getGroupPullJobMsgList(GroupPullJobMsgQuery);
    }

    @ApiOperation(value = "获取批量拉群任务机器人应用列表", notes = "获取批量拉群任务机器人应用列表",response = GroupSendTaskDeviceConfigVo.class)
    @PostMapping(value ="/getDeviceList" )
    public Object getDeviceList(@RequestBody WwDeviceQuery wwDeviceQuery)throws Exception{
        return  groupPullTaskService.getDeviceList(wwDeviceQuery);
    }

    @ApiOperation(value = "批量设置机器人应用列表休眠规则", notes = "批量设置机器人应用列表休眠规则",response = Boolean.class)
    @PostMapping(value ="/batchUpdateSleepRule" )
    public Object batchUpdateSleepRule(@RequestBody BatchUpdateSleepRuleDto batchUpdateSleepRuleDto)throws Exception{
        batchGroupPullTaskService.batchUpdateSleepRule(batchUpdateSleepRuleDto);
        return true;
    }

    @ApiOperation(value = "暂停任务执行列表", notes = "暂停任务执行列表",response = Boolean.class)
    @PostMapping(value ="/breakGroupPullJob" )
    public Object breakGroupPullJob(@RequestBody GroupPullJobDto groupPullJobDto)throws Exception{
        groupPullTaskService.breakGroupPullJob(groupPullJobDto);
        return true;
    }

    @ApiOperation(value = "继续任务执行列表", notes = "继续任务执行列表",response = Boolean.class)
    @PostMapping(value ="/continueGroupPullJob" )
    public Object continueGroupPullJob(@RequestBody GroupPullJobDto groupPullJobDto)throws Exception{
        groupPullTaskService.continueGroupPullJob(groupPullJobDto);
        return true;
    }

    @ApiOperation(value = "取消任务执行列表", notes = "取消任务执行列表",response = Boolean.class)
    @PostMapping(value ="/cancelGroupPullJob" )
    public Object cancelGroupPullJob(@RequestBody GroupPullJobDto groupPullJobDto)throws Exception{
        groupPullTaskService.cancelGroupPullJob(groupPullJobDto);
        return true;
    }


    @ApiOperation(value = "删除任务执行列表", notes = "删除任务执行列表",response = Boolean.class)
    @PostMapping(value ="/delGroupPullJob" )
    public Object delGroupPullJob(@RequestBody GroupPullJobDto groupPullJobDto)throws Exception{
        groupPullTaskService.delGroupPullJob(groupPullJobDto);
        return true;
    }

    @ApiOperation(value = "获取生效群", notes = "获取生效群", response = EffectuateGroupVo.class)
    @PostMapping("/getEffectuateGroup")
    public Object getEffectuateGroup(@RequestBody EffectuateGroupDto effectuateGroupDto)throws Exception{
        return groupPullTaskService.findAddFangetEffectuateGroupGroup(effectuateGroupDto);
    }
}
